<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
#use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('admin_menus')) return;
        Schema::create('admin_menus', function (Blueprint $table) {
            $table->id()->unsigned()->autoIncrement();
            $table->string('menu_no')->default('')->index()->comment('编码');
            $table->string('name')->default('')->index()->comment('名称');
            $table->string('class_name')->default('')->comment('按钮类名');
            $table->unsignedInteger('pid')->default(0)->index()->comment('上级ID');
            $table->boolean('level')->default(1)->index()->comment('等级');
            $table->boolean('type')->default(0)->index()->comment('类型：1菜单 2操作按钮');
            $table->boolean('is_win')->default(0)->comment('是否为窗口菜单：1是 0否');
            $table->string('icon')->default('')->comment('图标');
            $table->string('uri')->default('')->comment('路由');
            $table->unsignedInteger('sort')->default(0)->comment('排序，越小越靠前');
            $table->boolean('btn_type')->default(0)->comment('按钮类型：1普通操作 2查询 3导出 4弹窗 5保存');
            $table->boolean('is_delete')->default(0)->comment('是否删除：1是 0否');
            $table->boolean('is_export')->default(0)->comment('是否导出：1是 0否');
            $table->dateTime('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
        DB::statement("ALTER TABLE `admin_menus` COMMENT '后台菜单'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (!is_production()) Schema::dropIfExists('admin_menus');
    }
};
